# -*- cperl -*-
{
    my @files = ( "a.txt", "b.txt", );
    do { unlink if -f } for @files;

    my $runner = $smart . ' -f ' . $file;
    my @temp = `$runner 2>> $file.log`;
    do {
        -f or do {
            push @result, "FAILED: $_ not created";
            die "file $_ does generated";
        }
    } for @files;
    #pop @temp;
    push @result, @temp;
    push @result, "====================\n";

    @temp = `$runner 2>> $file.log`;
    #pop @temp;
    push @result, @temp;
    push @result, "====================\n";

    system("rm -f " . join " ", @files ) == 0 or do {
        push @result, "ERROR: can't rm @files\n";
        die "can't rm files @files";
    };
    @temp = `$runner 2>> $file.log`;
    #pop @temp;
    push @result, @temp;
    push @result, "====================\n";

    @temp = `$runner 2>> $file.log`;
    #pop @temp;
    push @result, @temp;
    push @result, "====================\n";

    system("sleep 2; touch b.txt;" ) == 0 or do {
        push @result, "ERROR: can't touch b.txt\n";
        die "can't touch file b.txt";
    };
    @temp = `$runner 2>> $file.log`;
    #pop @temp;
    push @result, @temp;
    push @result, "====================\n";

    @temp = `$runner 2>> $file.log`;
    #pop @temp;
    push @result, @temp;
    push @result, "====================\n";

    {
        open F, "<a.txt" or do {
            push @result, "ERROR: can't open a.txt for reading: $!";
            die "can't open a.txt: $!";
        };
        @temp = <F>;
        my $str = join '', @temp;
        push @result, "FAILED: a.txt not contains with 'foobar\\n'\n"
            unless $str eq "foobar: a.txt <- b.txt\n";
        close F;
    }

    do { unlink if -f } for @files;
    print "";
}
